package com.hehe.Config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class ResourceConfig implements WebMvcConfigurer {
    /*
     * 图片保存路径，自动从yml文件中获取数据
     */
    @Value("${file.upload.path}")
    private String fileSavePath;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        /*
            配置资源映射
         */
        registry.addResourceHandler("/upload/**").addResourceLocations("file:" + fileSavePath);
    }
}

